#include <bits/stdc++.h>
using namespace std;
int maxn = -1;
int n;
int arr[40];
int colour[40];
int calc(){
    int ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=i-1;j>=1;j--){
            if(colour[i]==colour[j]){
                if(arr[i]==arr[j]){
                    ans = ans + arr[j];
                }
                break;
            }
        }
    }
    return ans;
}
void dfs(int x, int c){
    if(x>n){
        maxn = max(maxn, calc());
        return ;
    }
    colour[x] = c;
    dfs(x+1, 1);
    dfs(x+1, 0);
}
int main(){
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    int t;
    cin >> t;
    while(t!=0){
        cin >> n;
        for(int i=1;i<=n;i++){
            cin >> arr[i];
        }
        dfs(0, true);
        cout << maxn << "\n";
        maxn = -1;
        t--;
    }
    return 0;
}
